var db  = require('../utils/db.js'); 
var redis  = require('../utils/zredis.js')(); 

var moment  = require('../utils/moment.min.js'); 
console.log(moment(Date.now()).format('YYYY-MM-DD HH:mm:ss') )
//var  userGetSql = 'SELECT * FROM user';
//var  userGetSql = 'INSERT INTO user(name,id) VALUES(\'xuzheng\',\'10001\')';
var KEY = 'key-data';
var Flag = true;
setInterval(function(){

    var date =  new Date();
    var year = date.getFullYear();
    var month = date.getMonth()+1;
    var day = date.getDay();
    var hour = date.getHours();
    var min = date.getMinutes();
    var sec = date.getSeconds();

    //console.log(date);
    //console.log(Flag);
    if (min%2 ===0 && Flag) {
        Flag =false;
        console.log(date);
        /*
        db.query(userGetSql,function(err,rows){
            if(err){
                console.log("query: "+err);
            }else{          
                console.log(rows);       
            }
        });	
        */
        redis.GetData(KEY,function(err,res){
		
            if(err){
                console.log('redis.GetData:'+err);  
            }else{
                console.log('redis.GetData:'+res);
                /*
                db.query(userGetSql,function(err,rows){
                    if(err){
                        console.log("query: "+err);
                    }else{          
                        console.log(rows);       
                    }
                });
                */	
            }
            
        });
        
    }; 
    if(min%2 !==0){
        Flag = true;
        //console.log('min:'+min);
    };
	
},500);





	
	
	
//exports.query = query;


